package fhp.hlhj.giantfold.presenter

import com.lzy.okgo.model.HttpParams
import fhp.hlhj.giantfold.interfaces.IGoodsFgm
import fhp.hlhj.giantfold.javaBean.ErroBean
import fhp.hlhj.giantfold.javaBean.SuperMarketListBean
import fhp.hlhj.giantfold.module.SuperMarketListModule

/**
 * author: FHP
 * data: on 2017\12\4 0004 17:38
 * E-Mail: 103945089@qq.com
 */
class SuperMarketListPresenter(private val iGoodsFgm: IGoodsFgm) : SuperMarketListModule.isOkListener {
    /**
     * 获得下一页数据
     */
    override fun overNextPage(superMarketListBean: SuperMarketListBean) {
//        iGoodsFgm.loadNextPage(superMarketListBean.proList.data)
    }
    private val superMarketListModule =SuperMarketListModule()

    fun getGoods(params: HttpParams){
        superMarketListModule.getGoods(params,this)
    }

    /**
     * 更改布局
     */
    fun changeLayout(){
        iGoodsFgm.changeLayout()
    }
    /**
     * 设置监听
     */
    fun setLoadListener(){
        iGoodsFgm.setLoadmorde()
    }
    /**
     *
     * 加载下一页
     */
    fun loadNextPage(params: HttpParams,url:String){
        superMarketListModule.getNextPageGoods(params,this,url)
    }

    /**
     * 获取数据
     */
    override fun over(superMarketListBean: SuperMarketListBean) {
        iGoodsFgm.getGoods(superMarketListBean)
    }

    /**
     * 加载
     */
    override fun showLoading() {
        iGoodsFgm.showLoading()
    }

    /**
     * 错误
     */
    override fun erro(erro: ErroBean) {
        iGoodsFgm.onError(erro)
    }
}